package com.xnsy.jishexiangmu.config;

import com.xnsy.jishexiangmu.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).excludePathPatterns("/user/login", "/user/register","/article/getall","/user/login2",
                "/article/getarticle",
                "/school/get",
                "/luntan/get",
                "/school/**");
    }

//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**")  // 匹配了所有的URL
//                .allowedHeaders("*")  // 允许跨域请求包含任意的头信息
//                .allowedMethods("*")  // 设置允许的方法
//                .allowedOrigins("*")  // 设置允许跨域请求的域名
//                .allowCredentials(true);  // 是否允许证书，默认false
//    }
}
